<?php
class SettingAction extends CommonAction{
    public function index() {
        $sets = getSetting();
        $this->assign('sets', $sets);
        $this->display();
    }

    public function update() {
        $infoPage = $this->_post('info_page');
        $adminPage = $this->_post('admin_page');
        $keyword = $this->_post('keyword');
        $description = $this->_post('description');
        $filterword = $this->_post('filterword');
        if(empty($infoPage) || empty($adminPage)) $this->error('分页填写不能为空!', 0);
        if(!is_numeric($infoPage) || !is_numeric($adminPage)) $this->error('分页填写必须为数字!', 0);
        $xmlstr = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<setting>
    <info_page>$infoPage</info_page>
    <admin_page>$adminPage</admin_page>
    <keyword>$keyword</keyword>
    <description>$description</description>
    <filterword>$filterword</filterword>
</setting>
XML;
        file_put_contents('Conf/setting.xml', $xmlstr);
        $this->success('修改成功!', __URL__);
    }
}
?>